package cn.hh.org.service.impl;

import cn.hh.basic.service.impl.BasicServiceImpl;
import cn.hh.org.domain.Employee;
import cn.hh.org.mapper.EmpMapper;
import cn.hh.org.service.IEmpService;
import cn.hh.user.domain.LoginInfo;
import cn.hh.user.mapper.LoginInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class EmpServiceImpl extends BasicServiceImpl<Employee> implements IEmpService{
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private LoginInfoMapper loginInfoMapper;
    @Override
    public void add(Employee employee) {
        LoginInfo logininfo = new LoginInfo();
        logininfo.setUsername(employee.getUsername());
        logininfo.setPhone(employee.getPhone());
        logininfo.setEmail(employee.getEmail());
        logininfo.setSalt(employee.getSalt());
        logininfo.setPassword(employee.getPassword());
        logininfo.setType(0);
        logininfo.setDisable(1);
        loginInfoMapper.add(logininfo);
        System.out.println("添加返回的主键"+logininfo.getId());
        employee.setLogininfo_id(logininfo.getId());
        empMapper.add(employee);
    }

}
